<template>
	<view>
		<view class="account-grouping">
			<view class="account-row">
				<view class="account-row-left">
					姓名
				</view>
				<view class="account-row-right">
					<view class="account-row-val">
						{{userinfo.nickname}}
					</view>
					<view class="user-arrow">
						<image class="img-full" src="@/static/home/arrow-right.png"></image>
					</view>
				</view>
			</view>
			<view class="account-row">
				<view class="account-row-left">
					手机号
				</view>
				<view class="account-row-right">
					<view class="account-row-val">
						{{userinfo.mobile}}
					</view>
					<view class="user-arrow">
						<image class="img-full" src="@/static/home/arrow-right.png"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="account-grouping">
			<view class="account-row">
				<view class="account-row-left">
					开户银行卡
				</view>
				<view class="account-row-right">
					<view class="account-row-val">

					</view>
					<view class="user-arrow">
						<image class="img-full" src="@/static/home/arrow-right.png"></image>
					</view>
				</view>
			</view>
			<view class="account-row">
				<view class="account-row-left">
					开户银行名称
				</view>
				<view class="account-row-right">
					<view class="account-row-val">

					</view>
					<view class="user-arrow">
						<image class="img-full" src="@/static/home/arrow-right.png"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="bottom-but">
			<view class="submit-but" @click="exit">
				退出登录
			</view>
		</view>
	</view>
</template>

<script>
	import Socket from '@/utils/ws.js'
	import Socket1 from '@/utils/ws1.js'
	import {
		cleanUserInfo
	} from "@/utils//utils.js";
	export default {
		data() {
			return {
				userinfo: {},
			}
		},
		onShow() {

			console.log(Socket, Socket1, '0000000000000')


			Socket.socketTask['login'].onMessage((res) => {
				console.log(res, '=========>')
				var arr = res.data.split('|');
				// console.log(arr, '====>arr')
				var type = arr[0];
				if (type == "LO") //登出返回
				{

					var Td = JSON.parse(arr[1]);
					console.log(Td, '===>退出返回')
					uni.clearStorageSync()

					// #ifdef H5
					uni.closeSocket()
					Socket1.socketTask['login1'] = null;
					Socket.socketTask['login'] = null;

					// #endif

					// #ifdef APP-PLUS
					Socket.socketTask['login'].close({
						success(res) {
							console.log("关闭成功", res)
							Socket.socketTask['login'] = null;
						},
						fail(err) {
							console.log("关闭失败", err)
						}
					})

					Socket1.socketTask['login1'].close({
						success(res) {
							console.log("关闭成功", res)
							Socket.socketTask['login1'] = null;
						},
						fail(err) {
							console.log("关闭失败", err)
						}
					})
					// #endif

					uni.reLaunch({
						url: '/pages/logon/logon/logon'
					})
				}
			});
			// this.$request({
			// 	url: this.$api.getUserInfo,
			// 	data: {},
			// 	method: 'get',
			// 	successCb: (res) => {
			// 		uni.hideLoading();
			// 		this.userinfo = res.data;
			// 		// console.log(res);
			// 	},
			// 	failCb(e) {
			// 		// uni.hideLoading();
			// 		console.log(e);
			// 		uni.showToast({
			// 			title: e.data.msg||'服务器异常',
			// 			icon: "none",
			// 			duration: 2000,
			// 		});
			// 	}
			// });
		},
		methods: {
			exit() {
				// cleanUserInfo()
				// uni.navigateBack()
				uni.showModal({
					title: '提示',
					content: '是否退出登录',
					success: (res) => {
						if (res.confirm) {
                           uni.clearStorageSync()
							uni.reLaunch({
								url: '/pages/logon/logon/logon'
							})
							Socket.socketTask['login'].send({
								data: ("LO|" + uni.getStorageSync('td')),
								success: () => {
									console.log("发送websocket中...");
								},
								fail: (err) => {}

							})
						}
					}
				})


			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F7F7F7;
	}

	.account-grouping {
		background-color: #fff;
		padding: 0 32rpx;
		margin-top: 20rpx;

		.account-row {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 28rpx 0;
			border-bottom: 2rpx solid #F5F5F5;

			.account-row-left {
				font-size: 28rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: rgba(0, 0, 0, 0.6);
			}

			.account-row-right {
				display: flex;
				align-items: center;

				.account-row-val {
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					color: rgba(0, 0, 0, 0.8);
				}

				.user-arrow {
					width: 36rpx;
					height: 48rpx;
				}
			}
		}
	}

	.bottom-but {
		position: fixed;
		bottom: 0%;
		left: 0;
		width: 100%;
		height: 200rpx;
		padding: 32rpx 64rpx;
		box-sizing: border-box;
		background-color: #fff;
		box-shadow: 0rpx 0rpx 16rpx 2rpx rgba(51, 51, 51, 0.2);

		.submit-but {
			width: 622rpx;
			height: 88rpx;
			background: #EE5953;
			border-radius: 16rpx;
			font-size: 34rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			line-height: 88rpx;
			text-align: center;
		}
	}
</style>